import { useHistory } from 'umi';
import { useEffect, useState } from 'react';

export default () => {
  const history = useHistory();
  const [query, setQuery] = useState((history.location as any).query);

  useEffect(() => {
    history.listen(() => {
      setQuery((history.location as any).query);
    });
  });

  return [
    query,
    (val: any) => {
      setQuery({ ...val });
      //
      // history.replace({
      //   pathname: history.location.pathname,
      //   query: {}
      // })
      console.log('sethistory', history);
    },
  ];
};
